#include "mainwidget.h"
#include "ui_mainwidget.h"

MainWidget::MainWidget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::MainWidget)
{
    ui->setupUi(this);
    //showWindowDebug();
    glWidget = new OpenGLWidget();
//    norWidget = new NormalWidget();
    QSurfaceFormat format;
    format.setSamples(4);
    format.setRenderableType(QSurfaceFormat::OpenGL);
    format.setProfile(QSurfaceFormat::CoreProfile);
    glWidget->setFormat(format);
    glWidget->resize(800, 600);
    glWidget->show();
//    norWidget->resize(800, 600);
//    norWidget->show();
}

MainWidget::~MainWidget()
{
    delete ui;
}

void MainWidget::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event)
    glWidget->resize(ui->paintWidget->width(), ui->paintWidget->height());
//    norWidget->resize(ui->paintWidget->width(), ui->paintWidget->height());
}

void MainWidget::showWindowDebug()
{
    qDebug() << "Group 1:";
    qDebug() << this->window();
    qDebug() << this->isWindow();
    qDebug() << this->windowHandle();
    qDebug() << this->windowType();
    qDebug() << ui->paintWidget->window();
    qDebug() << ui->paintWidget->isWindow();
    qDebug() << ui->paintWidget->windowHandle();
    qDebug() << ui->paintWidget->windowType();
    qDebug() << "Group 2:";
    qDebug() << this->winId();
    qDebug() << this->windowHandle();
    qDebug() << ui->paintWidget->windowHandle();
    qDebug() << ui->paintWidget->winId();
    qDebug() << ui->paintWidget->windowHandle();
}

